package org.zxl.api.common;

import org.zxl.api.common.dto.CloudRequestEntity;
import org.zxl.api.platform.dto.AuthInfo;
import org.zxl.api.platform.dto.LoginReqDTO;
import org.zxl.api.platform.service.PlatformService;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author zhangxiaolong
 * @date 2025-02-18 09:55
 **/
public class PlatformInfoCache {
    /**
     * 登录请求信息
     */
    private static final Map<String, CloudRequestEntity<LoginReqDTO>> loginReqEntityMap = new ConcurrentHashMap<>();

    /**
     * 登录成功返回的信息
     */
    private static final Map<String, AuthInfo> authInfoMap = new ConcurrentHashMap<>();


    private static final Map<String, PlatformService> platformServiceMap = new ConcurrentHashMap<>();

    public static void clear(String platformUuid) {
        loginReqEntityMap.remove(platformUuid);
        authInfoMap.remove(platformUuid);
        platformServiceMap.remove(platformUuid);
    }

    public static void putAuthInfo(String platformUuid, AuthInfo authInfo) {
        authInfoMap.put(platformUuid, authInfo);
    }
    public static AuthInfo getAuthInfo(String platformUuid) {
        return authInfoMap.get(platformUuid);
    }
    public static void putPlatformService(String platformUuid, PlatformService platformService) {
        platformServiceMap.put(platformUuid, platformService);
    }
    public static PlatformService getPlatformService(String platformUuid) {
        return platformServiceMap.get(platformUuid);
    }

    public static void putLoginReqEntity(String platformUuid, CloudRequestEntity<LoginReqDTO> loginReqEntity) {
        loginReqEntityMap.put(platformUuid, loginReqEntity);
    }

    public static CloudRequestEntity<LoginReqDTO> getLoginReqEntity(String platformUuid) {
        return loginReqEntityMap.get(platformUuid);
    }

}
